package com.loren.oauth.utils;

import java.util.Random;

public class DataUtils {

    public static String getRandomString(int length) {
        String resource = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1234567890";
        return getRandom(resource, length);
    }

    public static String getRandomNumber(int length) {
        String resource = "1234567890";
        return getRandom(resource, length);
    }

    private static String getRandom(String resource, int length) {
        Random random = new Random();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < length; i++) {
            builder.append(resource.charAt(random.nextInt(resource.length())));
        }
        return builder.toString();
    }
}
